package com.laxia.exception.ensure.extensions;

import com.laxia.exception.ExceptionFactory;
import com.laxia.exception.ensure.EnsureParam;


public class EnsureParamBooleanExtension extends EnsureParam<Boolean> {

    private Boolean condition;

    public EnsureParamBooleanExtension(Boolean condition) {
        super(condition);
        this.condition = condition;
    }

    public EnsureParamBooleanExtension isFalse(String errMsg, Object... objects) {
        if (condition) {
            throw ExceptionFactory.create(errMsg, objects);
        } else {
            return this;
        }
    }

    public EnsureParamBooleanExtension isTrue(String errMsg, Object... objects) {
        if (!condition) {
            throw ExceptionFactory.create(errMsg, objects);
        } else {
            return this;
        }
    }

}
